package com.neuedu.web.utils;

/**
 * @author 金山
 * 项目：javaweb
 * site: https://blog.fulfill.com.cn
 * 描述  通用的返回结果
 * @data 2024/11/198:46
 */
public class Res {
    private Integer code;
    private String msg;
    private Object data;


    private Res(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }


    public static Res urlNotFound(){
        return new Res(404,"请求路径不存在",null);
    }

    public static Res error(){
        return error("内部错误");
    }

    public static Res ok(Object data){
        return new Res(200,"",data);
    }

    public static Res error(String msg){
        return new Res(500,msg,null);
    }

    public static Res unauthorized  (){
        return new Res(401,"请求没有经过'授权",null);
    }


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
